﻿using System.Collections.Generic;
using System.Web.UI;
using System;
public static class PageExtensions
{
    public static IEnumerable<Control> All(this ControlCollection controls)
    {
        foreach (Control control in controls)
        {
            foreach (Control grandChild in control.Controls.All())
                yield return grandChild;

            yield return control;
        }
    }

    public static void ForEach<T>(this IEnumerable<T> collection, Action<T> function)
    {
        foreach (T item in collection)
        {
            function(item);
        }
    }
}